double SumFac(int x){
    double fac, sum;
    fac = 1;
    sum = 1;
    for(int i = 1; i <= x; i++){
        fac *= i;
        sum += fac;
    }
    return sum;
}